package com.shensi.adminCollect.controller.market;

import com.shensi.common.core.domain.AjaxResult;
import com.shensi.adminCollect.common.exception.CustomException;
import com.shensi.adminCollect.domain.markert.vo.YunHuaOrderVo;
import com.shensi.adminCollect.service.markert.YunHuaOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RequestMapping("/syncYunHuaOrder")
@RestController
@Slf4j
public class YunHuaOrderSyncController {
    @Resource
    private YunHuaOrderService yunHuaOrderService;


    @PostMapping("/addYunHuaOrder/{timestamp}/{sign}")
    public AjaxResult addYunhuaOrder(@RequestBody @Valid YunHuaOrderVo yunHuaOrderVo) {
        log.info("无感同步过来的订单【{}】", yunHuaOrderVo);
        if(!"1".equals(yunHuaOrderVo.getStatus()) &&  !"3".equals(yunHuaOrderVo.getStatus())){
            throw new CustomException("status错误");
        }

        return yunHuaOrderService.insertPayOrderForYunHua(yunHuaOrderVo);
    }
}
